package com.es.test;

import com.es.AopJavaApp;
import com.es.controller.StudentController;
import com.es.service.EmployeeService;
import com.es.service.StudentService;
import com.es.service.TeacherService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringAOP {

    AnnotationConfigApplicationContext ctx = null;
    @Before
    public void before(){
       ctx =  new AnnotationConfigApplicationContext(AopJavaApp.class);
    }

    @Test
    public void studentService(){
        StudentService service = ctx.getBean(StudentService.class);
        service.save();
        service.delete();
        service.update();
    }

    @Test
    public void teacherService(){
        TeacherService service = ctx.getBean(TeacherService.class);
        service.save();
      //  service.delete();
        service.update();
    }


    @Test
    public void throwingAdvice(){
        TeacherService service = ctx.getBean(TeacherService.class);
        service.delete();

    }

    @Test
    public void empServicve(){
        EmployeeService employeeService = ctx.getBean(EmployeeService.class);
        employeeService.save();
    }
    @After
    public void after(){
        ctx.close();
    }

    @Test
    public void annoAOP(){
        StudentController studentController = ctx.getBean(StudentController.class);
        studentController.add();
    }

}
